##package app

window.app = {}

( ->

##private

##public
  app.input_methods = {}

  app.reload_progress = (in_this_class, fn)->
    app.points_request = $.getJSON '/points', { 'u': login.user }, (data) ->
      $('#pointsbox span.points').text "#{data} points -"
    if in_this_class
      app.rank_request = $.getJSON '/points/rank', { l: login.language, c: login.class, u: login.user }, (data) ->
        rank = data.pop()
        if rank == 1 then rank = "1st" else if rank == 2 then rank = "2nd" else rank = rank + "rd"
        $('#pointsbox span.rank').text "#{rank} in class"
    else
      $('#pointsbox span.rank').text "Not in this class"
    vocab.reload_progress fn

##initialize

  app.initialize = ->
    #TODO: not $.support.placeholder untested!
    if not $.support.placeholder
      $('.cf').each ->
        $(this).val $(this).attr('placeholder')
      $('.cf').clearField()
    $('#lnt').notify()
    $('#ent').notify({ expires: 15000 })
    $('.jqt').jqTransform()
    $('#lefthidebutton').click ->
      if app.lefthidden
        app.lefthidden.show()
        app.lefthidden = null
      else
        app.lefthidden = $('.sidebar.sleft:visible')
        app.lefthidden.hide()
    $('#righthidebutton').click ->
      if app.righthidden
        app.righthidden.show()
        app.righthidden = null
      else
        app.righthidden = $('.sidebar.sright:visible')
        app.righthidden.hide()

  app.set_class = ->
    #TODO: set current class

##end

)()
